package cn.syc.struck.demo.http.service;

import cn.syc.struck.demo.http.HttpMethods;
import cn.syc.struck.demo.http.InterfaceApi.BlogInterface;
import cn.syc.struck.demo.http.entity.gen.BlogPager;
import cn.syc.struck.demo.http.entity.gen.MePager;
import rx.Observable;
import rx.Subscriber;

/**
 * Created by chenzz on 2017/3/18.
 */

public class BlogService extends HttpMethods {

    //获取单例
    public static BlogService getInstance() {
        return new BlogService();
    }

    private BlogInterface apiInterface;

    private BlogService() {
        super();
        apiInterface = retrofit.create(BlogInterface.class);
    }

    public void getBlogs(int p, Subscriber<BlogPager> subscriber) {
        Observable observable = apiInterface.getblogs(p).map(new HttpMethods.HttpResultFunc<BlogPager>());
        toSubscribe(observable, subscriber);
    }

    public void jsonpager(int p, Subscriber<MePager> subscriber) {
        Observable observable = apiInterface.jsonpager(p, null).map(new HttpMethods.HttpResultFunc<MePager>());
        toSubscribe(observable, subscriber);
    }
}
